
/*
 *      http.h
 *      
 *      Copyright 2009 Aaron Lehrian <jsmaster@tampabay.rr.com>
 *      
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */


#include <stdlib.h>
#include <network.h>


using namespace std;


enum net_protocol{
	UDP,
	TCP
};
struct _httpresponse{
  float version;
  int response_code;
  char *text;
  char *date;
  char *modified;
  char *server;
  size_t content_length;
  char *content_type;
  char *charset;
 
}httpresponse;
	
	
class internet{
	public:
		internet();
		~internet();
		void connect(char *server, int port,net_protocol protocol);
		int getnetstate();
		const char *getstate();
		void writetosocket(const char *write);
		char *readfromsocket(int bufsize = 1025);
		char *read(int bufsize = 1025);
		char *getipbyname(char *domain);
		char *address_to_ip(char *address_in);
	protected:
		char localip[16];
		char gateway[16];
		char netmask[16];
		s32 netstate;
	
	private:
		int offset;
		u32 ipaddr;
		int red;
		char *buff;
		s32 socket;
		hostent *hostip;
		char *host;
};

class http : public internet{

public:
http();
~http();
char *gethttpfile(const char *file,char *host,int bufsize = 1025);
protected:

private:
	httpresponse *response;
	char *httpget;
}; 
